package com.uowenjie.config;

import com.uowenjie.filter.MyGatewayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class TestFilterConfig {

    @Bean
    public RouteLocator getRouteLocator(RouteLocatorBuilder builder){
        RouteLocatorBuilder.Builder gateway1 = builder.routes().route(predicateSpec -> predicateSpec
                .path("/api/client/**")
                .filters(f -> f.stripPrefix(2).filter(getMayGateWayFilter()))
                .uri("http://localhost:10001")
                .order(0)
                .id("gateway-client")
        );
        return gateway1.build();
    }

    @Bean
    public MyGatewayFilter getMayGateWayFilter(){
        return new MyGatewayFilter();
    }

//    @Bean("myRemoteAddKeyResolver")
//    public MyRemoteAddKeyResolver getKey(){
//        return new MyRemoteAddKeyResolver();
//    }


}
